package com.androturka.billintur.cyberpark;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Common {

	final static String TAG = "Cyberpark";
	
	public static boolean isNextMonth(Date date) {
		
		Date today = new Date();
		
	    Calendar calendar = new GregorianCalendar();
	    calendar.setTime(date);
	    int mountMenu = calendar.get(Calendar.MONTH);

	    Calendar todayCalendar = new GregorianCalendar();
	    todayCalendar.setTime(today);
	    int mountToday = todayCalendar.get(Calendar.MONTH);
	    
	    if ( mountMenu > mountToday )
	    	return true;
	    else if (( mountToday == 12 ) && ( mountMenu == 1 ))
	    	return true;
	    	    
	    return false;
	}
	
	public static boolean isPastDate(Date date) {
		Date today = new Date();

	    Calendar calendar = new GregorianCalendar();
	    calendar.setTime(date);

	    Calendar todayCalendar = new GregorianCalendar();
	    todayCalendar.setTime(today);
	    
	    return calendar.before(todayCalendar);
	}

	public static int getDayOfWeek(Date date) {
	    Calendar calendar = new GregorianCalendar();
	    calendar.setTime(date);
	    
	    return calendar.get(Calendar.DAY_OF_WEEK);
	}
	
	public static boolean isToday(Date date) {
		Date today = new Date();

	    Calendar calendar = new GregorianCalendar();
	    calendar.setTime(date);

	    Calendar todayCalendar = new GregorianCalendar();
		todayCalendar.setTime(today);

	    return (calendar.get(Calendar.DATE) == ( todayCalendar.get(Calendar.DATE)));
	}
	
	public static boolean isinSameWeek(Date date) {		
		Date today = new Date();

	    Calendar calendar = new GregorianCalendar();
	    calendar.setTime(date);

	    Calendar todayCalendar = new GregorianCalendar();
	    todayCalendar.setTime(today);

	    return (calendar.get(Calendar.WEEK_OF_YEAR) == todayCalendar.get(Calendar.WEEK_OF_YEAR) );
	}
	
	public static Date convertStrToDate(String tarihStr) throws ParseException {
		
		SimpleDateFormat sdfSource = new SimpleDateFormat("dd.MM.yyyy");	     
		Date date = sdfSource.parse(tarihStr);
		
		return date;
	}

	public static String getDateStr(){
		SimpleDateFormat formatter ; 
		Date date = new Date();  
		formatter = new SimpleDateFormat("dd.MM.yyyy");
		String s = formatter.format(date);
				  
		return s;		
	}
}
